Skip to content

Add simple thread-safe queue implementation#7390

Open
prashantpiyush1111 wants to merge 18 commits intoTheAlgorithms:masterfrom
prashantpiyush1111:feature/thread-safe-queue
Open

Add simple thread-safe queue implementation#7390
prashantpiyush1111 wants to merge 18 commits intoTheAlgorithms:masterfrom
prashantpiyush1111:feature/thread-safe-queue

Conversation

@prashantpiyush1111
Copy link
Copy Markdown
Contributor

This PR adds a simple thread-safe queue implementation using Java synchronization.

Features:

  • Node-based linked list implementation
  • Thread-safe enqueue and dequeue using synchronized methods
  • Basic operations: enqueue, dequeue, and isEmpty
  • Simple and educational design

Motivation:

This implementation helps demonstrate:

  • Mutual exclusion using synchronized
  • Avoidance of race conditions
  • Behavior of data structures in a multithreaded environment

A simple test example is also included to show multithreaded usage.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.57%. Comparing base (763b95b) to head (6ee6b34).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7390      +/-   ##
============================================
+ Coverage     79.55%   79.57%   +0.02%     
- Complexity     7178     7194      +16     
============================================
  Files           798      800       +2     
  Lines         23467    23504      +37     
  Branches       4617     4619       +2     
============================================
+ Hits          18668    18703      +35     
- Misses         4054     4055       +1     
- Partials        745      746       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@JPB17387 JPB17387 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a test comment.

Comment thread src/main/java/com/thealgorithms/stacks/StackUsingLinkedList.java
Comment thread src/main/java/com/thealgorithms/stacks/StackUsingLinkedList.java
@prashantpiyush1111
Copy link
Copy Markdown
Contributor Author

Hi maintainers,

The implementation is complete with:

  • Thread-safe queue using synchronized
  • Unit tests added
  • Checkstyle issues fixed

All comments have been addressed. Kindly review and approve.

@prashantpiyush1111
Copy link
Copy Markdown
Contributor Author

@DenizAltunkapan @yanglbme @alxkm

Hi maintainers,
The PR is ready with implementation, tests, and formatting fixes.
Could you please review and provide feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants